﻿using System.Net;
using System.Threading.Tasks;

namespace Letter.Net.Kcp;

sealed class KcpServer : AKcpHost, IKcpServer
{
    public KcpServer(string name) : base(name)
    {
    }
    
    public override EndPoint BindEndPoint { get; }

    public override void Build()
    {
        base.Build();
    }

    protected override AConnection ConfigureConnection()
    {
        return new SUdpConnection(this.transportOptions, CreateConnection, this.channelProvider);
    }

    public override async Task BindAsync(EndPoint endPoint)
    {
        if (this.host == null)
        {
            return;
        }
        
        await host.BindAsync(endPoint);
    }

    public override Task StopAsync()
    {
        return this.host.StopAsync();
    }
}